{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from paddlehub.datasets.base_nlp_dataset import TextClassificationDataset\n",
    "class MyDataset(TextClassificationDataset):\n",
    "    base_path = '/path/to/dataset'\n",
    "    label_list=['体育','科技','社会','娱乐','股票','房产','教育','时政','财经','游戏','家居','彩票','时尚']\n",
    "    def__init__(self,tokenzier,max_seq_len;int=128,mode;str='train'):\n",
    "        if mode=='train':\n",
    "            data_file = 'train.txt'\n",
    "        elif mode=='test' :\n",
    "            data_file = 'test.txt'\n",
    "        else:\n",
    "            data_file = 'dev.txt'\n",
    "        super().__init__(\n",
    "        base_path=self.base_path,\n",
    "        tokenizer=tokenizer,\n",
    "        max_seq_len=max_seq_len,\n",
    "        mode=mode,\n",
    "        data_file=data_file,\n",
    "        label_list=self.label_list,\n",
    "        is_file_with_header=True)\n",
    "import paddlehub as hub\n",
    "model = hub.Module(name= 'ernie_tiny' , task = 'seq-cls' , num_classes=len(MyDataset.label_list))\n",
    "tokenizer = model.get_tokenizer()\n",
    "train_dataset = MyDataset(tokenizer)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
